<%@page pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
		<title>${initParam.WxAppName}</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/bettery/css/life.css">
		<link href="${pageContext.request.contextPath}/bettery/css/bootstrap.min.css" rel="stylesheet" />
		<link href="${pageContext.request.contextPath}/bettery/css/app.v2.css" rel="stylesheet" />
		<link href="${pageContext.request.contextPath}/bettery/css/jquery.bxslider.css" rel="stylesheet" />
		<link href="${pageContext.request.contextPath}/bettery/css/jquery-ui.css" rel="stylesheet" />
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
		<script src="${pageContext.request.contextPath}/bettery/js/jquery-ui-1.10.4.custom.min.js"></script>
		<style type="text/css">
html,body {
	background: #fff;
}

.thClass {
	border-bottom: 1px solid #cccccc;
	font-weight: normal;
	font-style: "微软雅黑";
	font-size: 15px;
	color: #3b3b3b;
	border-right: 1px solid #cccccc;
	height: 45px;
	background: #ececec;
	text-align: center;
	line-height: 44px;
}

.current_th {
	background: #fff;
	border-bottom: none;
}

.pane .span-more {
	min-height: 1px;
	padding-left: 15px;
	padding-right: 15px;
	position: relative;
}
</style>
		<script type="text/javascript">
var static = "${initParam.staticPath}";
$(function()
{
	$($('.tabClass tr th').get(0)).click();
	scrollLoad();
});
function queryMore(divId, nextId, status, paystate, transport_status, obj)
{
	$.ajax(
	{
		url : 'queryMoreOrder.xhtml?t=' + (new Date()),
		type : 'post',
		data :
		{
			'nextId' : nextId,
			'status' : status,
			'paystate' : paystate,
			'transport_status' : transport_status
		},
		dataType : 'json',
		success : function(data)
		{
			if (data.orderist.length > 0)
			{
			var order = data;
			var orderist = data.orderist;
			var nextId = data.nextId;
			for ( var i = 0; i < orderist.length; i++)
			{
			var html = "<div  class='panel'><div class='panel-heading'>支付订单号：" + orderist[i].payid + "</div><div  class='panel-body'><form id='orderFrom_" + orderist[i].id + "'>";
			var orderGoodsList = orderist[i].orderGoodsList;
			for ( var j = 0; j < orderGoodsList.length; j++)
			{
			html += "<div> <div class='panel-body'> <div style='display: inline-block; vertical-align: top;'>";
			var thub = static + orderGoodsList[j].goods.goods_thumb;
			if ('' == orderGoodsList[j].goods.goods_thumb)
			{
			thub = "${pageContext.request.contextPath}/img/logo2.jpg";
			}
			html += "<img src='${pageContext.request.contextPath}/img/loading.gif' xSrc='" + thub + "' style='width: 60px; height: 60px' /></div>";
			html += "<div style='display: inline-block; vertical-align: top;'><div> " + orderGoodsList[j].goods_name + "</div><div> 数量：" + orderGoodsList[j].order_num
					+ "</div><div> 待付款 </div> </div> </div> <div>";
			html += "<span class='pull-right'>总价:<span style='color: red;'>￥" + orderist[i].order_value + " </span> </span> </div></div><hr />";
			}
			html += "</form></div></div>"
			$("#" + divId).append(html);
			}
			if (nextId)
			{
			var p = $(obj).parent();
			$(obj).remove();
			p.html("<a style='width:100%;' onclick=\"queryMore('" + divId + "','" + nextId + "'," + status + "," + paystate + "," + transport_status + "this);\">点击查看更多</a>");
			}
			else
			{
			$(obj).parent().remove();
			}
			}
			else
			{
			$(obj).parent().remove();
			}
		}
	});
}
//延迟加载图片
var scrollLoad = (function(options)
{
	var defaults = (arguments.length == 0) ?
	{
		src : 'xSrc',
		time : 300
	} :
	{
		src : options.src || 'xSrc',
		time : options.time || 300
	};
	var camelize = function(s)
	{
		return s.replace(/-(\w)/g, function(strMatch, p1)
		{
			return p1.toUpperCase();
		});
	};
	this.getStyle = function(element, property)
	{
		if (arguments.length != 2)
			return false;
		var value = element.style[camelize(property)];
		if (!value)
		{
		if (document.defaultView && document.defaultView.getComputedStyle)
		{
		var css = document.defaultView.getComputedStyle(element, null);
		value = css ? css.getPropertyValue(property) : null;
		}
		else if (element.currentStyle)
		{
		value = element.currentStyle[camelize(property)];
		}
		}
		return value == 'auto' ? '' : value;
	};
	var _init = function()
	{
		var offsetPage = window.pageYOffset ? window.pageYOffset : window.document.documentElement.scrollTop, offsetWindow = offsetPage
				+ Number(window.innerHeight ? window.innerHeight : document.documentElement.clientHeight), docImg = document.images, _len = docImg.length;
		if (!_len)
			return false;
		for ( var i = 0; i < _len; i++)
		{
		var attrSrc = docImg[i].getAttribute(defaults.src), o = docImg[i], tag = o.nodeName.toLowerCase();
		if (o)
		{
		postPage = o.getBoundingClientRect().top + window.document.documentElement.scrollTop + window.document.body.scrollTop;
		postWindow = postPage + Number(this.getStyle(o, 'height').replace('px', ''));
		if ((postPage > offsetPage && postPage < offsetWindow) || (postWindow > offsetPage && postWindow < offsetWindow))
		{
		if (tag === "img" && attrSrc !== null)
		{
		o.setAttribute("src", attrSrc);
		}
		o = null;
		}
		}
		};
		window.onscroll = function()
		{
			setTimeout(function()
			{
				_init();
			}, defaults.time);
		}
	};
	return _init();
});
</script>

	</head>
	<body>
		<div class="wx_nav">
			<a class="nav_index" href="main.do">购物</a>
			<a class="nav_shopcart"  href="queryMyCar.do">购物车</a>
			<a class="nav_me on"  href="userInfo.do">个人中心</a>
		</div>
		
		<div style="height:90px;background: url('../bettery/img/welcomeorder.png') no-repeat;background-size:cover; width: 100%">
		
		<div style="border-radius: 20px; border: 1px solid #e6ecdd; width: 110px; height: 22px; background: rgba(230, 236, 221, 0.3); position: absolute; text-align: center; top:20px;right:10px;">
			<a href="queryUserAddr.do"> <img src="../bettery/img/dingwei.png" width="8" height="15" />收货地址管理 </a>
		</div>
		</div>
		
		<div>
			<table class="tabClass" cellpadding="0" cellspacing="0" style="width: 100%; text-align: center;">
				<tr>
					<th class="thClass">
						待发货(
						<span style="color: red">0</span>)
					</th>
					<th  class="thClass">
						待收货(
						<span style="color: red">0</span>)
					</th>
					<th style="border-right: none;"  class="thClass">
						已结束 (
						<span style="color: red">0</span>)
					</th>
				</tr>
			</table>
		</div>

		<div class="dfukuan_class pane" style="display: none;">
			<div id="waitPayList_orderist" class='col-lg-12 m-t'>
				<s:if test="waitPayList.size < 1">
					<div class="noneOrder">
						<p>
							没有待付款订单
						</p>

					</div>
				</s:if>
				<s:else>
					<s:iterator value="waitPayList.orderist" id="orderist">
						<div class='panel'>
							<div class='panel-heading'>
								支付订单号：${payid }
							</div>
							<div class='panel-body'>
								<form id="orderFrom_${id }">
									<s:hidden name="id"></s:hidden>
									<s:hidden name="orderNo"></s:hidden>
									<s:hidden name="orderAmount"></s:hidden>
									<s:iterator value="orderGoodsList">
										<div>
											<div class='panel-body'>
												<div style="display: inline-block; vertical-align: top;">
													<s:if test='null==goods.goods_thumb||""==goods.goods_thumb'>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${pageContext.request.contextPath}/img/logo2.jpg" style="width: 60px; height: 60px" />
													</s:if>
													<s:else>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${initParam.staticPath}${goods.goods_thumb}" style="width: 60px; height: 60px" />
													</s:else>
												</div>
												<div style="display: inline-block; vertical-align: top;">
													<div>
														${goods_name}
													</div>
													<div>
														数量：${order_num}
													</div>
													<div>
														待付款
													</div>
												</div>
											</div>
											<div>
												<span class='pull-right'>总价:<span style="color: red;">￥${orderist.order_value} </span> </span>
											</div>
										</div>
										<hr />
									</s:iterator>
								</form>
							</div>
						</div>
					</s:iterator>
				</s:else>

			</div>
			<s:if test="null!=waitPayList.nextId">
				<div class="col-lg-12 m-t" style="text-align: center; border: 1px;">
					<a style="width: 100%" onclick="queryMore('waitPayList_orderist','${waitPayList.nextId}',1,1,0,this);">点击查看更多</a>
				</div>
			</s:if>
		</div>

		<div class="daishouhuo_class pane">
			<div id="waitReciveList_orderist" class='col-lg-12 m-t'>
				<s:if test="waitReciveList.size < 1">
					<div class="noneOrder">
						<p>
							没有订单
						</p>
					</div>
				</s:if>
				<s:else>
					<s:iterator value="waitReciveList.orderist" id="orderist2">
						<div class='panel'>
							<div class='panel-heading'>
								订单号：${payid}
							</div>
							<div class='panel-body'>
								<form id="orderFrom_${id }">
									<s:hidden name="id"></s:hidden>
									<s:hidden name="orderNo"></s:hidden>
									<s:hidden name="orderAmount"></s:hidden>

									<s:iterator value="orderGoodsList">
										<div>
											<div class='panel-body'>
												<div style="display: inline-block; vertical-align: top;">
													<s:if test='null==goods.goods_thumb||""==goods.goods_thumb'>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${pageContext.request.contextPath}/img/logo2.jpg" style="width: 60px; height: 60px" />
													</s:if>
													<s:else>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${initParam.staticPath}${goods.goods_thumb}" style="width: 60px; height: 60px" />
													</s:else>
												</div>
												<div style="display: inline-block; vertical-align: top;">
													<div>
														${goods_name}
													</div>
													<div>
														数量：${order_num}
													</div>
													<div>
														等待确认收货
													</div>
												</div>
											</div>
											<div>
												<span class='pull-right'>总价:<span style="color: red;">￥${orderist2.order_value} </span> </span>
											</div>
										</div>
										<hr />
									</s:iterator>

									<div class="haveOrders" style="background: none; border: none;">
										<a class="btn btn-danger col-lg-12" onclick="shouHou(${id})"> 确认收货 </a>
									</div>
								</form>
							</div>
						</div>
					</s:iterator>
				</s:else>
			</div>
			<s:if test="null!=waitReciveList.nextId">
				<div class="col-lg-12 m-t" style="text-align: center; border: 1px;">
					<a style="width: 100%" onclick="queryMore('waitReciveList_orderist','${waitReciveList.nextId}',1,1,1,this);">点击查看更多</a>
				</div>
			</s:if>
		</div>

		<div class="yijieshu_class pane">
			<div id="finishedList_orderist" class='col-lg-12 m-t'>
				<s:if test="finishedList.size < 1">
					<div class="noneOrder">
						<p>
							没有订单
						</p>

					</div>
				</s:if>
				<s:else>
					<s:iterator value="finishedList.orderist" id="orderist3">
						<div class='panel'>
							<div class='panel-heading'>
								订单号：${orderNo }
							</div>
							<div class='panel-body'>
								<form id="orderFrom_${id }">
									<s:hidden name="id"></s:hidden>
									<s:hidden name="orderNo"></s:hidden>
									<s:hidden name="orderAmount"></s:hidden>
									<s:iterator value="orderGoodsList">
										<div>
											<div class='panel-body'>
												<div style="display: inline-block; vertical-align: top;">
													<s:if test='null==goods.goods_thumb||""==goods.goods_thumb'>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${pageContext.request.contextPath}/img/logo2.jpg" style="width: 60px; height: 60px" />
													</s:if>
													<s:else>
														<img src="${pageContext.request.contextPath}/img/loading.gif" xSrc="${initParam.staticPath}${goods.goods_thumb}" style="width: 60px; height: 60px" />
													</s:else>
												</div>
												<div style="display: inline-block; vertical-align: top;">
													<div>
														${goods_name}
													</div>
													<div>
														数量：${order_num}
													</div>
													<div>
														已完成订单
													</div>
												</div>
											</div>
											<div>
												<span class='pull-right'>总价:<span style="color: red;">￥${orderist3.order_value} </span> </span>
											</div>
										</div>
										<hr />
									</s:iterator>

								</form>
							</div>
						</div>
					</s:iterator>
				</s:else>
			</div>
			<s:if test="null!=finishedList.nextId">
				<div class="col-lg-12 m-t" style="text-align: center; border: 1px;">
					<a style="width: 100%" onclick="queryMore('finishedList_orderist','${finishedList.nextId}',3,1,1,this);">点击查看更多</a>
				</div>
			</s:if>
		</div>
	</body>
</html>